package com.ruoyi.inspection.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.inspection.domain.GovernCheckTaskFirm;
import com.ruoyi.inspection.service.GovernCheckTaskFirmService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 政府下发专项任务企业表(GovernCheckTaskFirm)表控制层
 *
 * @author makejava
 * @since 2024-06-18 10:48:34
 */
@RestController
@RequestMapping("/check/governCheckTaskFirm")
public class GovernCheckTaskFirmController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private GovernCheckTaskFirmService governCheckTaskFirmService;

    /**
     * 分页查询
     *
     * @param governCheckTaskFirm 筛选条件
     * @return 查询结果
     */
    @GetMapping("/list")
    public TableDataInfo queryByPage(GovernCheckTaskFirm governCheckTaskFirm) {
        startPage();
        List<GovernCheckTaskFirm> governCheckTaskFirms = this.governCheckTaskFirmService.queryByPage(governCheckTaskFirm);
        return getDataTable(governCheckTaskFirms);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public AjaxResult queryById(@PathVariable("id") Long id) {
        return AjaxResult.success(this.governCheckTaskFirmService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param governCheckTaskFirm 实体
     * @return 新增结果
     */
    @PostMapping
    public AjaxResult add(GovernCheckTaskFirm governCheckTaskFirm) {
        return AjaxResult.success(this.governCheckTaskFirmService.insert(governCheckTaskFirm));
    }

    /**
     * 编辑数据
     *
     * @param governCheckTaskFirm 实体
     * @return 编辑结果
     */
    @PutMapping
    public AjaxResult edit(GovernCheckTaskFirm governCheckTaskFirm) {
        return AjaxResult.success(this.governCheckTaskFirmService.update(governCheckTaskFirm));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public AjaxResult deleteById(Long id) {
        return AjaxResult.success(this.governCheckTaskFirmService.deleteById(id));
    }

}

